gint mouse_y;
gint pressed_button;
- gpointer group;
+ GQuark group;
guint dnd_timer;
guint switch_tab_timer;
PROP_SCROLLABLE,
PROP_PAGE,
PROP_ENABLE_POPUP,
- PROP_GROUP,
+ PROP_GROUP_NAME
};
enum {
GTK_PARAM_READWRITE));
/**
- * GtkNotebook:group:
- *
- * Group for tabs drag and drop.
+ * GtkNotebook:group-name:
*
- * Since: 2.12
- */
+ * Group name for tab drag and drop.
+ */
g_object_class_install_property (gobject_class,
- PROP_GROUP,
- g_param_spec_pointer ("group",
- P_("Group"),
- P_("Group for tabs drag and drop"),
- GTK_PARAM_READWRITE));
+ PROP_GROUP_NAME,
+ g_param_spec_string ("group-name",
+ P_("Group Name"),
+ P_("Group name for tab drag and drop"),
+ NULL,
+ GTK_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_TAB_LABEL,
priv->has_after_previous = 0;
priv->has_after_next = 1;
- priv->group = NULL;
+ priv->group = 0;
priv->pressed_button = -1;
priv->dnd_timer = 0;
priv->switch_tab_timer = 0;
case PROP_TAB_POS:
gtk_notebook_set_tab_pos (notebook, g_value_get_enum (value));
break;
- case PROP_GROUP:
- gtk_notebook_set_group (notebook, g_value_get_pointer (value));
+ case PROP_GROUP_NAME:
+ gtk_notebook_set_group_name (notebook, g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
case PROP_TAB_POS:
g_value_set_enum (value, priv->tab_pos);
break;
- case PROP_GROUP:
- g_value_set_pointer (value, priv->group);
+ case PROP_GROUP_NAME:
+ g_value_set_string (value, gtk_notebook_get_group_name (notebook));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
if (target == tab_target)
{
- gpointer widget_group, source_widget_group;
- GtkWidget *source_widget;
+ GQuark group, source_group;
+ GtkNotebook *source;
+ GtkWidget *source_child;
- source_widget = gtk_drag_get_source_widget (context);
- g_assert (source_widget);
+ source = GTK_NOTEBOOK (gtk_drag_get_source_widget (context));
+ source_child = source->priv->cur_page->child;
- widget_group = gtk_notebook_get_group (notebook);
- source_widget_group = gtk_notebook_get_group (GTK_NOTEBOOK (source_widget));
+ group = notebook->priv->group;
+ source_group = source->priv->group;
- if (widget_group && source_widget_group &&
- widget_group == source_widget_group &&
- !(widget == GTK_NOTEBOOK (source_widget)->priv->cur_page->child ||
- gtk_widget_is_ancestor (widget, GTK_NOTEBOOK (source_widget)->priv->cur_page->child)))
+ if (group != 0 && group == source_group &&
+ !(widget == source_child ||
+ gtk_widget_is_ancestor (widget, source_child)))
{
gdk_drag_status (context, GDK_ACTION_MOVE, time);
return TRUE;
}
/**
- * gtk_notebook_set_group:
+ * gtk_notebook_set_group_name:
* @notebook: a #GtkNotebook
- * @group: (allow-none): a pointer to identify the notebook group, or %NULL to unset it
+ * @name: (allow-none): the name of the notebook group, or %NULL to unset it
+ *
+ * Sets a group name for @notebook.
*
- * Sets a group identificator pointer for @notebook, notebooks sharing
- * the same group identificator pointer will be able to exchange tabs
- * via drag and drop. A notebook with a %NULL group identificator will
+ * Notebooks with the same name will be able to exchange tabs
+ * via drag and drop. A notebook with a %NULL group name will
* not be able to exchange tabs with any other notebook.
- *
- * Since: 2.12
*/
void
-gtk_notebook_set_group (GtkNotebook *notebook,
- gpointer group)
+gtk_notebook_set_group_name (GtkNotebook *notebook,
+ const gchar *group_name)
{
GtkNotebookPrivate *priv;
+ GQuark *group;
g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
priv = notebook->priv;
+ group = g_quark_from_string (group_name);
+
if (priv->group != group)
{
priv->group = group;
- g_object_notify (G_OBJECT (notebook), "group");
+ g_object_notify (G_OBJECT (notebook), "group-name");
}
}
/**
- * gtk_notebook_get_group:
+ * gtk_notebook_get_group_name:
* @notebook: a #GtkNotebook
*
- * Gets the current group identificator pointer for @notebook.
+ * Gets the current group name for @notebook.
*
- * Return Value: (transfer none): the group identificator,
+ * Return Value: (transfer none): the group name,
* or %NULL if none is set.
*
* Since: 2.12
**/
-gpointer
-gtk_notebook_get_group (GtkNotebook *notebook)
+const gchar *
+gtk_notebook_get_group_name (GtkNotebook *notebook)
{
g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL);
- return notebook->priv->group;
+ return g_quark_to_string (notebook->priv->group);
}
/**
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
notebook = gtk_notebook_new ();
- gtk_notebook_set_group (GTK_NOTEBOOK (notebook),
- gtk_notebook_get_group (source_notebook));
+ gtk_notebook_set_group_name (GTK_NOTEBOOK (notebook),
+ gtk_notebook_get_group_name (source_notebook));
gtk_container_add (GTK_CONTAINER (window), notebook);
static GtkWidget*
create_notebook (gchar **labels,
- gpointer group,
+ const gchar *group,
gint packing,
GtkPositionType pos)
{
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), pos);
gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
gtk_container_set_border_width (GTK_CONTAINER (notebook), 6);
- gtk_notebook_set_group (GTK_NOTEBOOK (notebook), group);
+ gtk_notebook_set_group_name (GTK_NOTEBOOK (notebook), group);
while (*labels)
{
static GtkWidget*
create_notebook_with_notebooks (gchar **labels,
- gpointer group,
+ const gchar *group,
gint packing,
GtkPositionType pos)
{
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), pos);
gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
gtk_container_set_border_width (GTK_CONTAINER (notebook), 6);
- gtk_notebook_set_group (GTK_NOTEBOOK (notebook), group);
+ gtk_notebook_set_group_name (GTK_NOTEBOOK (notebook), group);
while (*labels)
{